<template>
	<view class="">
		<z-paging ref="refPaging" v-model="dataInfo.list" @query="queryList">
			<view class="bgMinor2 heightAuto pd-24">
				<view class="">
					<!-- :itemStyle="{width:'50%',height: '44px'}" -->
					<!-- <uv-tabs
						:list="dataInfo.itemList"
						@click="clickList"
						lineWidth="60"
						:activeStyle="m_tabsActive"
						:inactiveStyle="m_tabsNoActive"
						:scrollable="false"
						lineColor="#FFB432"
						:current="dataInfo.current"
					></uv-tabs> -->

					<view class="flex color-black5 size-38">
						<view class="flex-1 tc tabItem height-76" @click="handleTabs(0)">
							<view class="Flex">
								<view class="tc line-hiding-1 mr-16"
									:class="{ 'color-black': dataInfo.current === 0, 'weight-6': dataInfo.current === 0 }">
									热门</view>
							</view>
							<view v-show="dataInfo.current === 0" class="height-6 width-120"
								style="background-color: #ffb432; margin: 0 auto; margin-top: 20rpx"></view>
						</view>
						<view class="flex-1 tabItem height-76" @click="handleTabs(1)">
							<view class="Flex">
								<view class="tc line-hiding-1 mr-16"
									:class="{ 'color-black': dataInfo.current === 1, 'weight-6': dataInfo.current === 1 }">
									脉星人</view>
								<uv-image v-if="dataInfo.current === 1" src="/static/images/vip2.png" width="38rpx"
									height="38rpx" mode="scaleToFill"></uv-image>
								<uv-image v-if="dataInfo.current === 0" src="/static/images/vip1.png" width="38rpx"
									height="38rpx" mode="scaleToFill"></uv-image>
							</view>
							<view v-show="dataInfo.current === 1" class="height-6 width-120"
								style="background-color: #ffb432; margin: 0 auto; margin-top: 20rpx"></view>
						</view>
					</view>
				</view>

				<view v-if="dataInfo.current === 0" class="">
					<!-- <plazaHot /> -->

					<scroll-view scroll-y style="height: 91vh" @scrolltolower="onScrollToLower" @scroll="onScroll"
						:scroll-top="dataInfo.defaultScrollTop">
						<!-- 嵌套子组件 -->
						<myOneClickChange name="5" ref="creativeCenterRef55" msg='1' />
						<!-- 模拟一些内容 -->
						<view v-for="i in 1" :key="i" style="visibility: hidden">{{ i }}</view>
					</scroll-view>

				</view>
				<view v-if="dataInfo.current === 1" class="">
					<!-- <plazaHot /> -->

					<scroll-view scroll-y style="height: 91vh" @scrolltolower="onScrollToLower" @scroll="onScroll"
						:scroll-top="dataInfo.defaultScrollTop">
						<!-- 嵌套子组件 -->
						<plazaVeinMan name="5" ref="creativeCenterRef1" msg='1' />
						<!-- 模拟一些内容 -->
						<view v-for="i in 1" :key="i" style="visibility: hidden">{{ i }}</view>
					</scroll-view>

				</view>

			</view>
		</z-paging>
	</view>
</template>

<script setup lang="ts">
	import { onMounted, reactive, ref } from 'vue';
	import { onLoad, onReachBottom, onHide, onShow, onPageScroll } from '@dcloudio/uni-app';
	import { getWindowHeight } from '@/pages/util/getHeight';
	import { addOpen, loggedIn, addOpenTab } from '@/pages/util/hooks';
	import plazaHot from './component/plaza-hot';
	import myOneClickChange from './component/myOneClickChangeF.vue';
	import plazaVeinMan from './component/plaza-vein-man';
	import useLoginStore from '@/pinia-store/userInfoStore';
	const useLogin = useLoginStore();
	const refPaging = ref(null);
	// console.log('useLoginuseLogin',useLogin);
	/** @name 数据 */
	const dataInfo = reactive({
		list: [],
		isComponentVisible: false,
		pageNo: 1, // 当前页数
		pageSize: 10, // 请求条数
		itemList: [{ name: '热门' }, { name: '脉星人', badge: { isDot: true, value: 5 } }],
		current: 0,
		defaultScrollTop: 0,
		componentKey: 0
	});
	const childComp = ref(null)
	function toggleComponent() {
		dataInfo.isComponentVisible = !dataInfo.isComponentVisible;
		dataInfo.componentKey++;
	}
	/** @name 切换选择 */
	function clickList(e) {

		dataInfo.current = e.index;

		console.log('eeeeeeee', e, dataInfo.current);
	}

	/** @name 下拉刷新组件方法 */
	function queryList(pageNo : number, pageSize : number) {
		dataInfo.pageNo = pageNo;
		dataInfo.pageSize = pageSize;
		// console.log('请求页码数pageNo',pageNo,pageSize);
		getMsgList();
	}
	function onScrollToLower() {
		console.log('---')

		creativeCenterRef55.value.ToLoweOnScrollr();
	}
	/** @name xxx */
	async function getMsgList() {
		// refPaging.value.complete(tempList);
	}

	const creativeCenterRef1 = ref(null)
	const creativeCenterRef55 = ref(null)
	async function handleTabs(index : number) {
		console.log(index)
		dataInfo.pageNo = 1;
		dataInfo.current = index;
		if (index == 0) {
			setTimeout(() => {
				creativeCenterRef55.value?.listFun();
			
			}, 100);

			
		}else{
			setTimeout(() => {
				creativeCenterRef1.value?.listFun();
			
			}, 100);
				
		}
	}

	const onScroll = (e) => {
		uni.setStorageSync('scrollTop', e.detail.scrollTop);
	}
	onLoad((options : any) => {

		// setTimeout(() => {
		// 	dataInfo.defaultScrollTop = 100
		// }, 1000)
	})
	onShow(() => {
		const pages = getCurrentPages();
		console.log(pages)
		const previousPage = pages[pages.length - 2];
		if (previousPage) {
			console.log('来源页面是：', previousPage.route);
			// 根据 previousPage.route 执行相应的逻辑
		}
	})
	onPageScroll((res) => {
		console.log(res.scrollTop, '距离页面顶部距离'); //距离页面顶部距离
	})
	// onMounted(()=>{
	//
	// })
</script>

<style scoped lang="scss">
	// :deep(.checklist-box) {
	// 	//  模版
	// }

	.itemClass {}
</style>